import request from '@/utils/request';

// 获取文章列表
export interface searchParams {
    /**
     * 分类id
     */
    categoryId?: string;
    /**
     * 咨询师姓名
     */
    name?: string;
    pageNum: number;
    pageSize: number;
    /**
     * 咨询师的userId
     */
    teacherId?: string;
    /**
     * 文章标题
     */
    title?: string;
    [property: string]: any;
}

export function getArticleList(data:searchParams) {
    return request({
        url: '/system/article/list',
        method: 'get',
        params: data
    });
}

//添加文章

export interface addRequest {
    /**
     * 分类id
     */
    categoryId: string;
    /**
     * 文本内容，富文本
     */
    content: any[] | boolean | number | number | { [key: string]: any } | null | string;
    /**
     * 文章标题
     */
    title: string;
    /**
     * 封面图片Url
     */
    titlePicture: string;
    /**
     * 权重
     */
    weight: number;
    // 时间
    // sendTime:string;
    [property: string]: any;
}

export function addArticle(data:addRequest) {
    return request({
        url: '/system/article',
        method: 'post',
        data:data
        // params: query
    });
}

// 删除
export function delArticle(ids) {
    return request({
        url: `/system/article/${ids}`,
        method: 'delete',
    });
}


//修改文章


export interface editRequest {
    /**
     * 分类id
     */
    categoryId: string;
    /**
     * 内容
     */
    content: any[] | boolean | number | number | { [key: string]: any } | null | string;
    /**
     * 文章id
     */
    id: string;
    /**
     * 文章标题
     */
    title: string;
    /**
     * 封面图片Url
     */
    titlePicture: string;
    [property: string]: any;
}

export function editArticle(data:editRequest) {
    return request({
        url: '/system/article',
        method: 'put',
        data:data
    });
}


// 获取分类列表
// export interface CategoryData {
//     pageNum?: string;
//     pageSize?: string;
//     [property: string]: any;
// }
export function getCategoryList() {
    return request({
        url: '/system/category/list',
        method: 'get',
        // data:data
    });
}


//详情

export function articleDetails(id) {
    return request({
        url: `/system/article/${id}`,
        method: 'get',
    });
}
